﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using coliseu.BussinessLayer;

namespace coliseu.Views.Condominio
{
    public partial class FrmListGaragem : Form
    {
        private BlocoBL bl = new BlocoBL();
        private GaragemBL gl = new GaragemBL();

        public FrmListGaragem()
        {
            InitializeComponent();
        }

        private void FrmListGaragem_Load(object sender, EventArgs e)
        {
            blocoBindingSource.DataSource = bl.selecionar();
        }

        private void blocoBindingSource_CurrentChanged(object sender, EventArgs e)
        {
            try
            {
                garagemBindingSource.DataSource = gl.selecionar(((bloco)blocoBindingSource.Current).id_bloco);
            }
            catch
            {
            }
        }

        private void toolStripButton4_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Deseja excluir?", "Confirmação", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
            {
                gl.excluir((garagem)garagemBindingSource.Current);
                garagemBindingSource.DataSource = gl.selecionar();
            }
        }

        private void toolStripButton1_Click(object sender, EventArgs e)
        {
            FrmCadGaragem c = new FrmCadGaragem(gl, ((bloco)blocoBindingSource.Current).id_bloco);
            c.ShowDialog();
            garagemBindingSource.DataSource = gl.selecionar(((bloco)blocoBindingSource.Current).id_bloco);
        }

        private void toolStripButton2_Click(object sender, EventArgs e)
        {
            FrmCadGaragem c = new FrmCadGaragem(((garagem)garagemBindingSource.Current), gl, ((bloco)blocoBindingSource.Current).id_bloco);
            c.ShowDialog();
            garagemBindingSource.DataSource = gl.selecionar(((bloco)blocoBindingSource.Current).id_bloco);
        }
    }
}
